package com.casework

class SearchTagLib {
    static namespace = "search"

    def highlight = {attrs, body ->
        String query = params.textQuery
        String text = body()

        query?.split(' ').each{ word ->
            if(word){
                text = text.replaceAll(/(?i)($word)/) {fullmatch, f ->
                        "<strong>$fullmatch</strong>"
                    }
            }
        }
        out << text
    }
}
